package com.zhihaoliang.room

import com.zhihaoliang.room.base.list.ListActivity
import com.zhihaoliang.room.base.list.ListItem


class MainActivity : ListActivity() {

    private lateinit var mainPresenter: MainPresenter

    override val listItem: List<ListItem> = listOf(
        ListItem("打印所有植物列表", 0),
        ListItem("User 数据插入", 1),
        ListItem("Fts4 User 数据插入", 2),
        ListItem("indices User 数据插入", 3),
        ListItem("Fts4 Match 搜索", 4),
        ListItem("Fts4 like 搜索", 5),
        ListItem("User like 搜索", 6),
        ListItem("like index 搜索", 7),
        ListItem("index 数据插入", 8),
        ListItem("嵌入对象的插入", 9),
        ListItem("一对一数据库插入", 10),
        ListItem("一对一数据搜索", 11),
        ListItem("一对多数据库插入", 12),
        ListItem("一对多数据搜索", 13),
    )

    override fun initView() {
        super.initView()
        mainPresenter = MainPresenter(mainScope,applicationContext)
    }

    override fun onItemClick(item: ListItem) {
        when (item.index) {
            0 -> mainPresenter.getPlants()
            1-> mainPresenter.insertUser()
            2-> mainPresenter.insertFtsUsers()
            3->mainPresenter.insertIndexUsers()
            4->mainPresenter.queryFtsMatchUsers()
            5->mainPresenter.queryFtsLikeUsers()
            6->mainPresenter.queryLikeUsers()
            7->mainPresenter.queryIndexLikeUsers()
            8->mainPresenter.insertIndexUser()
            9->mainPresenter.insertUserAd()
            10->mainPresenter.insertUserLibrary()
            11->mainPresenter.queryUsersAndLibraries()
            12->mainPresenter.insertUserPlayList()
            13->mainPresenter.queryUsersWithPlaylists()
        }
    }

}